package com.enjoyor.soa.traffic.server.efoms.dubbo.invoke;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.service.dubbo.idcs.DubboIDCSBayonetCallbackService;
import com.enjoyor.soa.traffic.api.service.dubbo.idcs.IDCSCallbackListener;

@Component
public class DubboBayonetCallbackServiceInvoke {

	@Reference(timeout = 10000)
    private DubboIDCSBayonetCallbackService bayonetCallbackService ;

	/**
	 * 订阅卡口状态
	 * @param listenerId 监听ID，不重复ID，可以为IP或者编号，只有一个web层可以不填
	 * @param listener 监听
	 */
	public void addBayonetStatusListener(String listenerId,IDCSCallbackListener listener) {
		if (null != bayonetCallbackService) {
			bayonetCallbackService.addBayonetStatusListener(listenerId, listener);
        }
	};
	
	/**
	 * 移除订阅
	 * @param listenerId 监听ID，不重复ID，可以为IP或者编号，只有一个web层可以不填
	 * @return 是否移除成功
	 */
	public boolean removeBayonetStatusListener(String listenerId) {
		Boolean flag = false;
		if (null != bayonetCallbackService) {
			flag = bayonetCallbackService.removeBayonetStatusListener(listenerId);
        }
		return flag;
	}
	
	/**
	 * 订阅卡口状态心跳
	 * @param listenerId 监听ID，不重复ID，可以为IP或者编号，只有一个web层可以不填
	 * @return
	 */
	public boolean BayonetStatusHeartBeat(String listenerId) {
		Boolean flag = false;
		if (null != bayonetCallbackService) {
			flag = bayonetCallbackService.BayonetStatusHeartBeat(listenerId);
        }
		return flag;
	}
}
